This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Aug 19, 2016, 12:00 PM
13 Posts

Where 8 < 8 is true?

  • Category: Domino Designer
  • Platform: Windows
  • Release: 9.0.1
  • Role:
  • Tags: Math compare if
  • Replies: 1

I have a timesheet database. In the Timesheet form, I have a field called "Time". This field is a dialog list (therefor text) with selections like:
00.10
00.20
.
.
01.10
01.20
.
.
10.10
10.20

etc. Time is measured in 10ths of an hour. I have an agent. Code follows

Sub Initialize
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim view As NotesView
 Dim doc As NotesDocument
 Dim key (1) As Variant
 Dim total As Double
 Dim well As Boolean
 
 Set db = session.currentdatabase
 Set view = db.getView("(DateEmpFlat)")
 key(0) = CDat("07/11/2016")
 key(1) = "Somebody's name"
 Set doc = view.Getdocumentbykey(Key)
 While doc.StaffName(0) = "Somebody's name"
  total = total + CDbl(doc.time(0))
  Set doc = view.Getnextdocument(doc)
 Wend
 If total < 8 Then
  well = True
 Else
  well = false
 End If
End Sub

When we add up all of the person's timesheet on a given day, the Double field: Total is = 8. This person has 40 documents of small increments of time that add up to 8.

Yet, the if statement results in the field "Well" being set to True

This doesn't happen for everyone. Just a few. Examining total between the ones that are 8 and fails the if statement (as it should) and the ones that don't fail the if statement shows no difference between the value of Total. I've even converted total to binary and in all cases the result is "1000". I've examined each of the document properties and found no difference between the ones where the if statement works and doesn't work. The number of documents we have to add up doesn't make a difference. The faulty calculation happens when adding up the time of as few as 4 documents.

My work around is to convert Total to a string then back to a Double again. Then the if statement works 100%

I think it might be some wierd parity issue, but this is basic math and if the compare doesn't work properly I really start to question notes ability to conduct basic math and compares.

Aug 19, 2016, 1:41 PM
1 Posts
Where 8 < 8 is true?

It could be that the value you think is 8 is actually 7.999.

Remember that comparisons between floating-point numbers (aka doubles aka a Notes Numeric item) must normally be done within a confidence range using something like @FloatEQ


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal